package com.acme.bankapp.service;

import com.acme.bankapp.domain.*;


public class BankService {
	static public void addClient(Bank bank, Client client) {
		bank.addClient(client);
	}
	
	public static void modifyBank(Bank bank) {
		Client[] clis = bank.getClients();
		int num = bank.getNumberOfClients();
		
		for (int i = 0; i < num; i++) {
			Account[] accs = clis[i].getAccounts();
			int num1 = clis[i].getNumberOfAccounts();
			for (int j = 0; j < num1; j++) {
				accs[j].withdraw(accs[j].getBalance()/2);
				accs[j].deposit(accs[j].getBalance()*3);
			}
		}
	}
	
	public static void printBalance(Bank bank) {
		Client[] clis = bank.getClients();
		int num = bank.getNumberOfClients();
		
		for (int i = 0; i < num; i++) {
			clis[i].getClientSituation();
			Account[] accs = clis[i].getAccounts();
			int num1 = clis[i].getNumberOfAccounts();
			for (int j = 0; j < num1; j++) {
				System.out.println(j +" account balance " + accs[j].getBalance());
			}
		}
	}
	
	public static void printMaximumAmountToWithdraw(Bank bank) {
		Client[] clis = bank.getClients();
		int num = bank.getNumberOfClients();
		
		for (int i = 0; i < num; i++) {
			clis[i].getClientSituation();
			Account[] accs = clis[i].getAccounts();
			int num1 = clis[i].getNumberOfAccounts();
			for (int j = 0; j < num1; j++) {
				System.out.println(j +" Maxium to withdraw: " + accs[j].maximumAmountToWithdraw());
			}
		}
	}

}
